<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>api 测试页面</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<script type="text/javascript">
		var ws = new WebSocket("ws://tc.moqbus.com:2885/");

		ws.onopen = function() {
			console.log("open");
			var data = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
			ws.send("REG:9535C48F,58D86CAA36;");
			ws.send(data);
		};

		ws.onmessage = function(evt){
			console.log("recieve message");
			console.log(evt.data);
		};

		ws.onclose = function(evt){
			console.log(evt);
			console.log("WebSocketClosed!");
		};

		ws.onerror = function(evt){
			console.log(evt);
			console.log("WebSocketError!");
		};

		function q(){
			ws.send(document.getElementById('msg').value);
		}

	</script>

</head>

<body>
	<textarea  rows="10" cols="50" id="msg"></textarea>
	<input type="button" value="发送" id="send" onclick="q()"/>

</body>
</html>
